package com.ticket.serviceImpl;

import com.ticket.pojo.DepartFromPort;
import com.ticket.service.IDepartFromPortService;

import javax.persistence.Table;

public class DepartFromPortServiceImpl extends BaseServiceImpl implements IDepartFromPortService {

	public DepartFromPort queryByFlightNoAndDate(String flightNumber, String departPortTime) {

		String sql = "select * from "
				+ ((Table) DepartFromPort.class.getAnnotation(Table.class)).name()
				+ " t where t.flt=? and date_format(t.flightDate,'%Y-%m-%d')=?";
		DepartFromPort departFromPort = this.dbDAO.executeSQLForQuerySingle(sql, DepartFromPort.class, flightNumber, departPortTime);
//		if (departFromPort.isEmpty()) {
//			Date date = new SimpleDateFormat("yyyy-MM-dd").parse(departPortTime);
//			return this.dbDAO.executeJPQLForQuerySingle(
//					"select * from " + DepartFromPort.class.getSimpleName() + " where flt=? and std=?",
//					DepartFromPort.class, flightNumber, date);
//		}

		return departFromPort;
	}
}